<template>
  <div id="indexHeader">
    <img src="../../assets/logo.png" id="logo" />
    <div id="mainwindowHandle">
      <el-tooltip content="最小化" placement="bottom" class="item">
        <div class="mini-max-close minimum" @click="click('minimum')"></div>
      </el-tooltip>
      <el-tooltip content="最大化" placement="bottom">
        <div class="mini-max-close maximum" @click="click('maximum')"></div>
      </el-tooltip>
      <el-tooltip content="关闭" placement="bottom">
        <div class="mini-max-close close" @click="click('close')"></div>
      </el-tooltip>
    </div>
  </div>
</template>

<script>
const { ipcRenderer } = window.require("electron");
export default {
  name: "IndexHeader",
  methods: {
    click(type) {
      if (type == "minimum") {
        ipcRenderer.send("change_mainWindow", type);
      } else if (type == "maximum") {
        ipcRenderer.send("change_mainWindow", type);
      } else if (type == "close") {
        const quitStatus = localStorage.getItem("quitStatus");
        if (quitStatus == "hide") {
          ipcRenderer.send("change_mainWindow", "close_hide");
        } else if (quitStatus == "quit") {
          ipcRenderer.send("change_mainWindow", "close_quit");
        } else if (quitStatus == null) {
          ipcRenderer.send("change_mainWindow", "close_null");
        }
      }
    },
  },
};
</script>

<style lang="scss" scoped>
#indexHeader {
  height: 60px;
  width: 100%;
  background-color: #222225;
  border-bottom: 2px solid #9c1a1a;
  z-index: 99;
  -webkit-app-region: drag;

  #logo {
    height: 55px;
    width: 55px;
    margin-top: 3px;
    margin-left: 30px;
  }

  #mainwindowHandle {
    width: 120px;
    height: 30px;
    float: right;
    margin-top: 15px;
    margin-right: 20px;
    -webkit-app-region: no-drag;

    .item {
      outline: none;
    }

    .minimum {
      background-image: url("../../assets/minimum.png");
    }

    .maximum {
      background-image: url("../../assets/maximum.png");
    }

    .close {
      background-image: url("../../assets/close.png");
    }

    .mini-max-close {
      height: 30px;
      width: 30px;
      margin-left: 10px;
      float: left;
      background-repeat: no-repeat;
      background-position: center center;
      background-size: 50%;
      cursor: pointer;
    }

    .minimum:hover,
    .maximum:hover {
      background-color: rgba(255, 255, 255, 0.2);
    }
    .close:hover {
      background-color: #9c1a1a;
    }
  }
}

/deep/ :focus {
  outline: none;
}
</style>
